Relay the xdg_output.name to GdkMonitor
authorEmmanuele Bassi <ebassi@gnome.org>
Thu, 20 Jun 2019 14:55:58 +0000 (15:55 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Mon, 24 Jun 2019 14:38:36 +0000 (15:38 +0100)
The xdg_output v2 interface has a `name` property that reflects the
output name coming from the compositor.

This is the closest thing we can get to a connector name.

gdk/wayland/gdkdisplay-wayland.c
gdk/wayland/gdkdisplay-wayland.h
gdk/wayland/gdkmonitor-wayland.c
gdk/wayland/gdkmonitor-wayland.h

index eb46fa42af54742ac2ec75b6774a0ec36f506b32..c02f7c66eb40ee66bf9ce90e2009fd77c089ebec 100644 (file)
@@ -531,8 +531,11 @@ gdk_registry_handle_global (void               *data,
     }
   else if (strcmp(interface, "zxdg_output_manager_v1") == 0)
     {
+      display_wayland->xdg_output_manager_version = MIN (version, 2);
       display_wayland->xdg_output_manager =
-            wl_registry_bind (registry, id, &zxdg_output_manager_v1_interface, 1);
+        wl_registry_bind (display_wayland->wl_registry, id,
+                          &zxdg_output_manager_v1_interface,
+                          display_wayland->xdg_output_manager_version);
       gdk_wayland_display_init_xdg_output (display_wayland);
       _gdk_wayland_display_async_roundtrip (display_wayland);
     }
@@ -2222,6 +2225,7 @@ apply_monitor_change (GdkWaylandMonitor *monitor)
 
   gdk_monitor_set_position (GDK_MONITOR (monitor), monitor->x, monitor->y);
   gdk_monitor_set_size (GDK_MONITOR (monitor), monitor->width, monitor->height);
+  gdk_monitor_set_connector (GDK_MONITOR (monitor), monitor->name);
   monitor->wl_output_done = FALSE;
   monitor->xdg_output_done = FALSE;
 
@@ -2272,10 +2276,36 @@ xdg_output_handle_done (void                  *data,
     apply_monitor_change (monitor);
 }
 
+static void
+xdg_output_handle_name (void                  *data,
+                        struct zxdg_output_v1 *xdg_output,
+                        const char            *name)
+{
+  GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
+
+  GDK_NOTE (MISC,
+            g_message ("handle name xdg-output %d", monitor->id));
+
+  monitor->name = g_strdup (name);
+}
+
+static void
+xdg_output_handle_description (void                  *data,
+                               struct zxdg_output_v1 *xdg_output,
+                               const char            *description)
+{
+  GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
+
+  GDK_NOTE (MISC,
+            g_message ("handle description xdg-output %d", monitor->id));
+}
+
 static const struct zxdg_output_v1_listener xdg_output_listener = {
     xdg_output_handle_logical_position,
     xdg_output_handle_logical_size,
     xdg_output_handle_done,
+    xdg_output_handle_name,
+    xdg_output_handle_description,
 };
 
 static void
index 6c5265f6a4b869cf5552d7286c2c01ac616cd621..11768033d234f809e58a96aca8fba706eeab3fb9 100644 (file)
@@ -137,6 +137,7 @@ struct _GdkWaylandDisplay
   int seat_version;
   int data_device_manager_version;
   int gtk_shell_version;
+  int xdg_output_manager_version;
 
   uint32_t server_decoration_mode;
 
index 189be0514ae5b9f24282911e63ea16245d4cf6f5..7f73dd66a69069e3ef60590f9b0f4e6d3de4dce2 100644 (file)
@@ -35,6 +35,8 @@ gdk_wayland_monitor_finalize (GObject *object)
 {
   GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)object;
 
+  g_free (monitor->name);
+
   wl_output_destroy (monitor->output);
 
   G_OBJECT_CLASS (gdk_wayland_monitor_parent_class)->finalize (object);
index 593ab1d85c378649f387833c4fcb424461d6772a..69592bd28abd34976569a163178de3a37b1ea7bd 100644 (file)
@@ -37,6 +37,7 @@ struct _GdkWaylandMonitor {
   int32_t y;
   int32_t width;
   int32_t height;
+  char *name;
   gboolean wl_output_done;
   gboolean xdg_output_done;
 };